import { defineStore } from "pinia";
import { postUsersList, newUserData, postPageListData } from '@/service/main/system/system'
import type { ISystemState } from './type' // 处理数据类型


const useSystemStore = defineStore("system", {
  state: (): ISystemState => ({
    userList: [],
    userTotalCount: 0,
    pageList: [],
    pageTotalCount: 0,
  }),
  actions: {
    async postUsersListAction() {
      // const usersListResult = await postUsersList()
      // console.log(usersListResult, '---')
      // const { totalCount, list } = usersListResult.data
      // this.userTotalCount = totalCount
      // this.userList = list
    },
    async newUserDataAction(userInfo: any) {
      // 1. 创建新的用户
      const newResult = await newUserData(userInfo)
      console.log(newResult, '---')
    },

    /** 部门列表 */
    async postPageListAction(pageName: string, queryInfo: any) {
      const pageListResult = await postPageListData(pageName, queryInfo)
      console.log(pageListResult, '---')
      const { list, totalCount } = pageListResult.data
      this.pageList = list
      this.pageTotalCount = totalCount
    },
  }
});
export default useSystemStore
